<?php
/**
 * UEditor 入口
 *
 * Author: Zeon
 * Date: 2018/2/25
 * Created by Panxsoft.
 */
namespace App\Http\Requests\Admin\UEditor;

use App\Http\Controllers\Admin\UEditorController;
use App\Http\Requests\ApiRequest;

/**
 * @property string action
 */
class UEditorActionRequest extends ApiRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'action' => 'required|in:' . implode(',', $this->getActions()) ,
        ];
    }

    /**
     * @return array
     */
    public function messages()
    {
        return [
            'action.*'     => '请使用指定的action动作',
        ];
    }

    /**
     * @return array
     */
    public function getActions()
    {
        return [
            UEditorController::ACTION_CONF,
            UEditorController::ACTION_UPLOAD_IMG,
        ];
    }
}
